package growth.net.utils;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.UUID;

public class Utils {

    public static String readValueFromCommmandLine() {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String value = null;
        byte[] bArray = new byte[1024];
        try {
            value = br.readLine();
        } catch (IOException ioe) {
            ioe.printStackTrace();
            System.exit(1);
        }
        return value;
    }

    public static String getUniqueId() {
        UUID uuidGenerator = UUID.randomUUID();
        return uuidGenerator.toString();
    }

    public static int getInteger() {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int value = -1;
        try {
            value = Integer.parseInt(br.readLine());
        } catch (IOException ioe) {
            ioe.printStackTrace();
            System.exit(1);
        }
        return value;
    }

    public static void showMenu(String peerName) {
        System.out.println("\nChoose option for : " + peerName);
        System.out.println("0: Who am I?");
        System.out.println("1: Spawn");
        System.out.println("2: Leave");
        System.out.println("3: Neighbours");
        System.out.println("4: Broadcase Message");
        System.out.println("5: Add Manually");
        System.out.println("6: Node Degree (Incedent Edges Count)");
        System.out.println("7: Get Network Info");
        System.out.println("8: Get All Node's Neighbor List");
    }

    public static String[] messageParser(String inMsg) {
        String[] partsOfMsg = inMsg.trim().split(",");
        return partsOfMsg;
    }

    public static void showMenuGraphGen() {
        System.out.println("\nChoose option");
        System.out.println("0: Random Leave");
        System.out.println("1: Random Spawn");

//        System.out.println("1: Spawn");
//        System.out.println("2: Leave");
//        System.out.println("3: Neighbours");
//        System.out.println("4: Broadcase Message");
//        System.out.println("5: Add Manually");
//        System.out.println("6: Node Degree (Incedent Edges Count)");
//        System.out.println("7: Get Network Info");
    }

    public static void showLeaveSubMenu() {
        System.out.println("\nChoose option");
        System.out.println("0: Link All ");
        System.out.println("1: Link Circular ");

    }

    public static void showAnalysisSubMenu() {
        System.out.println("\nChoose option");
        System.out.println("0: Min/Max Degree ");
        System.out.println("1: Diameter ");

    }
}
